import requests
from config import token


class Manager_user_api(object):

    # 管理端-用户---增加用户
    @classmethod
    def add_user(cls, json_data):
        url = "http://kaxiaoli.kalulibattery.com/battery-admin-api/user/add"
        headers = {"x-access-token": token}

        resq = requests.post(url=url, headers=headers, json=json_data)
        return resq.json()

    # 用户管理查询
    @classmethod
    def select_user_all(cls, json_data):
        url = "http://kaxiaoli.kalulibattery.com/battery-admin-api/user/query"
        resq = requests.post(url=url, headers={"x-access-token": token}, json=json_data)
        return resq.json()

    # 删除指定用户
    @classmethod
    def delete_user_Id(cls, userId):
        url = f"http://kaxiaoli.kalulibattery.com/battery-admin-api/user/delete/{userId}"
        resq = requests.post(url=url,headers={"x-access-token": token})
        return resq.json()

    # 更新用户信息
    @classmethod
    def update_user(cls,json_data):
        url = f"http://kaxiaoli.kalulibattery.com/battery-admin-api/user/update"
        resq = requests.post(url=url, headers={"x-access-token": token},json=json_data)
        return resq.json()
    #用户重置密码
    @classmethod
    def reset_pwd(cls,userId):
        url = f"http://kaxiaoli.kalulibattery.com/battery-admin-api/user/resetPasswd/{userId}"
        resq = requests.get(url=url, headers={"x-access-token": token})
        return resq.json()



if __name__ == '__main__':
    print(Manager_user_api.reset_pwd(8))